<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class ShopOrderDetails extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
      Schema::create('shop_order_details', function (Blueprint $table) {
        $table->increments('id');
        $table->unsignedInteger('order_id');
        $table->unsignedInteger('attr_id');
        $table->string('picurl', 255);
        $table->string('gname', 100);
        $table->tinyInteger('buynum');
        $table->decimal('price', 10, 2);
        $table->string('desc', 100);

        $table->foreign('order_id')
              ->references('id')->on('shop_orders')
              ->onDelete('cascade');

        $table->foreign('attr_id')
              ->references('id')->on('shop_goods_attrs')
              ->onDelete('cascade');
      });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
      Schema::dropIfExists('shop_order_details');

    }
}
